package org.dizena;

import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.Environment;

import java.net.InetAddress;
import java.net.UnknownHostException;

@Slf4j
@SpringBootApplication
public class StartMgrBootApp {
    public static void main(String[] args) throws UnknownHostException {
        SpringApplication application = new SpringApplication(StartMgrBootApp.class);

        ConfigurableApplicationContext context = application.run(args);
        Environment env = context.getEnvironment();
        String ip = InetAddress.getLocalHost().getHostAddress();
        String port = env.getProperty("server.port");
        String name = env.getProperty("spring.application.name");
        log.info("Application " + name + " started! Access URLs:\n\t" +
                "Local: \t\thttp://localhost:" + port + "\n\t" +
                "External: \thttp://" + ip + ":" + port + "\n\t" +
                "TestURL: \thttp://" + ip + ":" + port + "/index.html\n\t" +
                "Swagger文档: http://" + ip + ":" + port + "/doc.html");
    }

}
